package com.cjb.controller;

import com.cjb.entity.Department;
import com.cjb.response.Result;
import com.cjb.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author kuangjian
 * @since 2022-08-30
 */
@Api(value = "系统部门模块",tags = "系统部门接口")
//@CrossOrigin
@RestController
@RequestMapping("/department")
public class DepartmentController {

    @Autowired
    private DepartmentService departmentService;
    /**
     * 所有部门
     *
     * @return
     */
    @ApiOperation(value = "部门列表",notes = "查询所有部门及部门人数")
    @GetMapping("/getDepartNameAndCount")
    public Result getDepartNameAndCount() {
        List<Department> departments = departmentService.findAll();
        return Result.ok().data("departments",departments);
    }

}
